home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 #22 / q22.d81 / t.slide poker < prev    next >
Encoding:
Text File  |  1991-01-01  |  16.1 KB  |  331 lines

  1.  
  2.  
  3.                     SLIDE POKER 128 AND CONTROL80-C V1.1
  4.                                       
  5.                                by Jon Mattson
  6.                                       
  7.     (SLIDE POKER is based on a game by Maurice Jones and Fender Tucker)
  8.  
  9.  
  10.      Some time ago, while I was working on an 80-column Crazy Eights game
  11. for LS128, I decided to design a few standard routines that would simplify
  12. the creation of card games in general.  My first priority was to have
  13. large, crisp cards which would, nevertheless, be drawn quickly on the
  14. screen.  I also wanted the shuffle routine to be virtually instantaneous
  15. and the whole package to work with Control80, since I never program on the
  16. 80-column screen without that utility, these days.  (Fender says much the
  17. same.  All modesty aside, if you are a C128 programmer working with the 80-
  18. column screen you may want to try it out, too: it makes life much simpler.
  19. Plug, plug...)  It soon became clear that what I really needed to do was
  20. create a new version of Control80, specifically designed for card games,
  21. and that is exactly what I did.
  22.  
  23.      After the game was published, Fender took a look at the code and grew
  24. curious about the previously unseen keywords contained therein, so I filled
  25. him in on the new version of Control80, C80-C.  He realized, showing more
  26. foresight than I'm afraid I had displayed, that a lot of other people might
  27. find it handy if they knew how to use it, so he asked me to come up with
  28. another card game, specifically designed to showcase C80-C.  I was a bit
  29. stumped at first, because I wanted to do a card game unlike anything which
  30. had previously appeared on LS 128.  Fender soon came to the rescue again,
  31. though: he and Maurice Jones had recently finished a game for the C-64
  32. which he thought could be ported over to LS 128 with good effect.  Thus was
  33. born SLIDE POKER 128.
  34.  
  35.      There is really little more to be said about the game, since you can
  36. read all about it from within the program itself, simply by pressing 'R'.
  37. This is listed on the main screen, so you don't even have to remember that.
  38. The rest of this article will be devoted, instead, to C80-C and how you can
  39. make use of it.  Much of the following information will be familiar to
  40. those who have used Control80 before; however, it has been repeated here
  41. for those who have not.  Even veteran users should look this over and take
  42. note: for reasons of space, this run-time version does not include five of
  43. the old commands, namely DUMP, HOME, LCLEAR, VSAVE and MINE.  On the other
  44. hand, three new commands -- CARD, DICE and SHUF -- have been added, and
  45. FILL has been improved.  Also note that this version of C80-C (V1.1)
  46. supersedes the version which accompanied CRAZY EIGHTS (V1.0), since it
  47. improves upon the latter by adding Jokers to the deck.
  48.  
  49.      First of all, a quick overview is in order for those who have no idea
  50. what Control80 and its close cousin, C80-C, are all about.  Control80 is an
  51. extension of the BASIC 7.0 which adds many new keywords to the language.
  52. These new functions and commands are specifically designed to make using
  53. the 80-column screen easier.  Those who have tried to work with 80-columns
  54. in BASIC 7.0 will realize just what a boon this is: you can't even PEEK or
  55. POKE to the VDC with normal BASIC!  Control80 solves that problem and many
  56. others, as well.
  57.  
  58.      Using C80-C is simple.  First, set aside a section of memory to hold
  59. it by opening up the area normally used for hires graphics.  GRAPHIC1,1
  60. will accomplish this, although it should be followed by GRAPHIC0,1 to get
  61. out of hires mode and GRAPHIC5 to return the screen editor controls to the
  62. 80-column screen.  Then, just BLOAD C80-C into memory and SYS 4864, either
  63. in direct mode or early on in your program.  Generally a simple BLOAD will
  64. suffice, but, if you have been playing around with BANKs and the like, you
  65. might want to use the full syntax.  To summarize:
  66.  
  67.      GRAPHIC1,1:GRPAHIC0,1:GRAPHIC5:BLOAD"C80-C",B0,P4864:SYS4864
  68.  
  69.      Unlike Control80, C80-C comes with a built-in, card-oriented font,
  70. which can be moved to VDC memory with a simply FCOPY 6880,0,1.  This
  71. command will cause the new font to replace the existing alternate
  72. (upper/lower case) font, so that you can use the CARD command.  Once the
  73. font is in place, you can freely overwrite the area it previously occupied
  74. and even 'collapse' the graphic area with GRAPHICCLR to free up more
  75. program space if you wish, since C80-C, itself, resides below this area.
  76. As an aside, this is why you must open a graphics area for C80-C, whereas
  77. you do not need to do so with Control80.  For obvious reasons, the FCOPY
  78. should come very shortly after the set-up commands previously mentioned;
  79. however, it should not be on the same line as those commands.  The reason
  80. for this is that the computer deciphers keywords a line at a time, and,
  81. until the SYS 4864 has actually been acted upon, the FCOPY command will be
  82. translated as gibberish, resulting in a syntax error when that point in the
  83. line is reached.
  84.  
  85.      Once C80-C is installed, the new keywords can be used just like any
  86. other BASIC commands.  You can even abbreviate them by shifting the second
  87. letter, as usual.  Remember that C80-C must be active (not just resident)
  88. while you type in a program using its keywords, or they will not be
  89. tokenized correctly.  Note, also, that C80-C uses memory from 4864 to 6879
  90. (once the font has been moved), so avoid POKEing around this area.
  91.  
  92.      Hitting the beloved STOP/RESTORE combination will not deactivate C80-
  93. C.  The QUIT command (previously unimplemented on the 128) will turn it
  94. off, although SYS 4864 will bring it back to life.  Resetting the computer
  95. will also turn it off; however, due to its location, C80-C will still be
  96. resident for later use, as long as you haven't POKEd over its memory space.
  97. In this case, however, the font will likely be lost.
  98.  
  99.      Now let's look at your new resources.  Certain conventions have been
  100. followed in this listing.  Memory addresses are 0-65535, as usual, to allow
  101. use with both 16K and 64K VDCs.  Note, however, that addresses above 16383
  102. wrap around on the 16K chip, i.e. 16384 = 0.  Remember that the basic 8563
  103. chip is set up as follows:
  104.  
  105.      $0000 - 07FF        0 - 2047     Screen
  106.      $0800 - 0FFF     2048 - 4095     Attributes
  107.      $1000 - 1FFF     4096 - 8191     Unused
  108.      $2000 - 2FFF     8192 - 12287    Upper Case/Graphic (normal) Font
  109.      $3000 - 3FFF    12288 - 16383    Upper/Lower Case (alternate) Font
  110.  
  111.       VDC register numbers (reg# below) range from 0-36.  It is not within
  112. the scope of this article to explain the use of every register, but a
  113. simplified listing is given in the previous Control80 article, and a
  114. complete description can be found in the C-128 Programmer's Reference
  115. Guide.  When in doubt, experiment with the WVD command, but be sure that
  116. you check the register's normal value first with the RVD function to set
  117. things back to normal!
  118.  
  119.  
  120.                             ***  FUNCTIONS  ***
  121.  
  122. PEER (VDC address)
  123.  
  124.      This function allows you to check the contents of VDC memory.  It
  125. operates just like BASIC's PEEK.  For example, to find the character in the
  126. top left corner of the screen, PRINT PEER(0).  Note that PEER is the
  127. counterpart of POST, below.
  128.  
  129.  
  130. RVD (reg#)
  131.  
  132.      This function (Read ViDeo register) allows you to check the contents
  133. of any of the 37 VDC registers.  For example, A=RVD(12) would put the
  134. contents of register 12 into the variable A.  Note that RVD is the
  135. counterpart of WVD, below.
  136.  
  137.  
  138.                              ***  COMMANDS  ***
  139.  
  140. BLOCK VDC address, number, value
  141.  
  142.      This command allows you to fill any small section of VDC memory with a
  143. single value.  "Address" indicates the starting position of the fill, and
  144. "number" (2-255) indicates how many consecutive locations to fill with the
  145. specified "value" (0-255), from that point on.  One of the best uses of
  146. BLOCK is to highlight a line on the screen by filling attribute memory with
  147. a different color value and/or reverse.  For example, BLOCK 2048,80,72
  148. would highlight the entire first line of the screen by coloring it red and
  149. using reverse characters.  See FILL for more information on attribute
  150. memory.
  151.  
  152.  
  153. CARD top left corner address, card number
  154.  
  155.      This command draws the specified card on the screen with its top left
  156. corner positioned over the indicated address.  Card numbers are from 0-51
  157. for the basic deck and 52+ for Jokers.  The basic deck is divided into four
  158. groups of thirteen cards, in the following order: Clubs (0-12),  Spades
  159. (13-25), Hearts (26-38) and Diamonds (39-51).  Thus, 0 is the Ace of Clubs,
  160. 12 is the King of Clubs, 13 is the Ace of Spades, and so on.  The command
  161. CARD 0,2 would draw a three of Clubs in the top left corner of the screen.
  162. For this command to work properly, the C80-C font must be installed, the
  163. screen should be white (VCOL 16,1) and the background should be filled with
  164. a non-space character.  Due to the restrictions of the 80-column screen
  165. (i.e. no multicolor or extended color) and the fact that I wanted the cards
  166. to look as realistic and colorful as possible, I was forced to do without
  167. any sort of outlining.  This may sound like a restriction, but, after
  168. playing with the Tiles feature in SLIDE POKER for a few seconds, I'm sure
  169. you'll agree that it is a fairly trivial one.
  170.  
  171.  
  172. DICE type, number
  173.  
  174.      This command effectively rolls the indicated "type" of dice the
  175. specified "number" of times and puts the total in memory location 250.  For
  176. example, DICE 8,3:A=PEEK(250) would roll three eight-sided dice, for a
  177. result of 3 to 24, and put the total in the variable A.  A "type" of less
  178. than 2 returns a roll of 0-255, regardless of the "number".  A "type" of
  179. greater than 128, returns one roll of the appropriate type, regardless of
  180. the "number".  Since only one byte is used to store the result, the roll
  181. cannot exceed 255; thus, a DICE 50,50 command (with a maximum possible
  182. result of 2500) would return a pretty meaningless result most of the time.
  183. The best thing about this command, aside from its convenience, is that it
  184. does not use the random function of the SID chip and, thus, will never
  185. conflict with voice 3.  Like the RND function, this command should be re-
  186. seeded the first time it is called upon (only), as follows:
  187.  
  188.      I=RND(-TI):FORI=.TO15:POKE6025+I,INT(RND(1)*256):NEXT
  189.  
  190.  
  191. FCOPY address, bank, character set (0 or 1)
  192.  
  193.      This command allows you to convert and copy a standard 40-column font
  194. already in normal memory, at the "address" and "bank" specified, to the
  195. 8563 chip.  Since the 8563 allows two character sets to be displayed on the
  196. screen simultaneously, you must specify which one to replace: 0 for upper
  197. case/graphics (normal) or 1 for lower/upper case (alternate).  The font
  198. used with CARD should always be copied to the alternate set.
  199.  
  200.  
  201. FILL top left corner address, width, length, value
  202.  
  203.      This command fills a rectangular section of memory of the indicated
  204. "width" and "length" (height) with the specified "value", starting with the
  205. "top left corner address".  For example FILL 0,80,25,33 would fill the
  206. whole screen with exclamation marks (screen code 33); FILL 2048,40,10,154
  207. would cause a rectangular 40 by 10 area in the top left corner of the
  208. screen to be "painted" with purple, flashing, alternate characters.  When
  209. using FILL and similar commands, remember that the attribute codes are as
  210. follows:
  211.  
  212.      Bit 7 (128)  Alternate Font
  213.          6 (64)   Reverse Video
  214.          5 (32)   Underline             Thus, in the example above, 154 =
  215.          4 (16)   Flash                 128 for alternate font
  216.          3 (8)    Red                   +16 for flash
  217.          2 (4)    Green                 +10 for purple (red + blue)
  218.          1 (2)    Blue
  219.          0 (1)    Intensity
  220.  
  221.  
  222. FINIT
  223.  
  224.      This command simply reinitializes the 8563's normal fonts.  It is
  225. useful for cancelling the effects of FCOPY or undesirable POSTs into
  226. character memory.
  227.  
  228.  
  229. POST VDC address, value
  230.  
  231.      This command allows you to place values into 8563 memory.  It operates
  232. just like BASIC's POKE.  For example, POST 0,1 will place an "A" in the top
  233. left corner of the screen.  Note that POST is the counterpart of the PEER
  234. function.
  235.  
  236.  
  237. RECALL bytes, VDC address, from RAM address, from bank
  238.  
  239.      This command copies chunks of memory from normal RAM to 8563 VDC RAM.
  240. "Bytes" (1-65535) indicates the number of bytes to copy.  "Address" and
  241. "bank" ranges are as per usual, 0-65535 and 0-15, respectively.  When used
  242. in conjunction with STORE, this command can create "pop up" windows.  For
  243. example, after opening up some free RAM space with the GRAPHIC command, as
  244. previously explained, you could use the following procedure:
  245.  
  246. (1) STORE 4096,0,8192,0 to move the 4096 bytes of screen and attribute
  247. memory to location 8192 in bank 0.
  248.  
  249. (2) Open your window, as usual, with the WINDOW command, or form an
  250. appropriate area with FILL.
  251.  
  252. (3) When you are finished with the window, have the original screen
  253. reappear with RECALL 4096,0,8192,0.
  254.  
  255.  
  256. STORE bytes, VDC address, to RAM address, to bank
  257.  
  258.      This command copies chunks of memory from 8563 VDC RAM to normal RAM.
  259. It is the reverse of RECALL, above, and its use is more fully explained in
  260. that command's description.
  261.  
  262.  
  263. SHUF data address, number of Jokers (0-4)
  264.  
  265.      This command will "shuffle" numbers from 0 to 51 in 52 "slots", each
  266. representing a card, as for the CARD command.  This range and number of
  267. "slots" is increased by the "number of Jokers" specified.  The shuffle
  268. begins at the indicated "data address", usually the start of an integer
  269. variable array, and goes up in steps of two, for use with integer
  270. variables; thus, 104 bytes are used for the basic deck, plus 2 bytes per
  271. Joker.  The integer variable that will hold the "deck" should be defined in
  272. advance, so that the "data address" can be set using the BASIC 7.0 POINTER
  273. command.  This may sound complex to explain, but it is actually quite
  274. simple to use.  For example, to shuffle a deck with 52 normal cards and 2
  275. Jokers you would use something like this: DIM C%(53):SHUF POINTER(C%(0)),2.
  276. The integer variable array C%() would end up containing a randomly ordered
  277. list of 54 numbers, each representing a card.  Best of all, this command
  278. works almost instantly -- vastly quicker than any comparable BASIC routine.
  279. Note that SHUF uses the same randomizing routine as DICE; thus, it should
  280. be re-seeded once at the beginning of your program before being used, as
  281. explained for the latter command.
  282.  
  283.  
  284. VCOL background, foreground
  285.  
  286.      This command alters the background and default foreground colors of
  287. the screen.  Note that the foreground color is actually used very little,
  288. unless you turn off the screen attributes.  As usual, color values must
  289. range from 1 to 16; however, since some of these values are not the same as
  290. on the 40-column screen, you may wish to experiment a bit.
  291.  
  292.  
  293. VLOAD "filename", VDC start address
  294.  
  295.      This command works in much the same manner as BLOAD except that data
  296. is loaded into VDC memory.  The starting address is optional and defaults
  297. to the location from which the data was saved.  Remember that variable
  298. strings used for filenames must be enclosed in parentheses.  Note that
  299. BLOAD/BSAVE and VLOAD are compatible: memory BSAVEd from RAM can be VLOADed
  300. into VDC memory.  Whether or not the data will have any meaning in this new
  301. context is another matter.
  302.  
  303.  
  304. WVD reg#, value
  305.  
  306.      This command (Write to ViDeo register) allows you to write directly to
  307. the 8563 registers.  For example, WVD 26,242 would put 242 in register 26,
  308. altering the screen color.  This command is the counterpart of the RVD
  309. function.  Note that some registers have bits which cannot be altered
  310. directly by the user; thus, the value you enter with WVD may look different
  311. if you later read the same register with RVD.
  312.  
  313.  
  314. QUIT
  315.  
  316.      This command simply turns off C80-C.  SYS 4864 to reactivate it.
  317.  
  318.  
  319.      If you are interested in programming card games yourself or simply
  320. want to use the many other commands available in C80-C, I strongly urge you
  321. to study the program listing for SLIDE POKER.  It has been fairly heavily
  322. REMed for this purpose and should answer any questions you might have at
  323. this point, particularly with regards to managing a deck of cards on your
  324. computer.  After designing your own game, you might even want to send it to
  325. LS128.  Who knows?  There might be fame and fortune in the cards for you!
  326.  
  327. DJM
  328.  
  329.                  \\\\\  R - Run    RETURN - Menu  \\\\\
  330.  
  331.